package com.sunda.spmsoversea.mapper;

import com.sunda.spmsoversea.entity.OverseaWhsMoveDtl;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 海外仓调拨任务明细 Mapper 接口
 * </p>
 *
 * @author Wayne
 * @since 2022-01-20
 */
@Mapper
public interface OverseaWhsMoveDtlMapper extends BaseMapper<OverseaWhsMoveDtl> {

    @Select("SELECT OWM.UUID AS \"uuid\",\n" +
            "       OWM.WERKS_MOVE_OUT AS \"werksMoveOut\",\n" +
            "       OWM.WHS_LOCATION_CODE_MOVE_OUT AS \"whsLocationCodeMoveOut\",\n" +
            "       OWM.WERKS_MOVE_IN AS \"werksMoveIn\",\n" +
            "       OWM.WHS_LOCATION_CODE_MOVE_IN AS \"whsLocationCodeMoveIn\",\n" +
            "       OWMD.ITEM_NO AS \"itemNo\",\n" +
            "       OWMD.MATERIAL_NO AS \"materialNo\",\n" +
            "       MS.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "       MS.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "       MS.BASIC_UNIT AS \"basicUnit\",\n" +
            "       MS.UNIT_SALES AS \"unitSales\",\n" +
            "       OWMD.QTY_MOVE_OUT AS \"qtyMoveOut\",\n" +
            "       OWMD.STORAGE_INFO_MOVE_OUT AS \"storageInfoMoveOut\",\n" +
            "       OWMD.ACTUAL_QTY_MOVE_OUT AS \"actualQtyMoveOut\",\n" +
            "       OWMD.ACTUAL_STORAGE_INFO_MOVE_OUT AS \"actualStorageInfoMoveOut\",\n" +
            "       OWMD.REMARK_MOVE_OUT AS \"remarkMoveOut\",\n" +
            "       OWMD.ACTUAL_QTY_MOVE_IN AS \"actualQtyMoveIn\",\n" +
            "       OWMD.ACTUAL_STORAGE_INFO_MOVE_IN AS \"actualStorageInfoMoveIn\",\n" +
            "       OWMD.REMARK_MOVE_IN AS \"remarkMoveIn\"\n" +
            "FROM OVERSEA_WHS_MOVE_DTL OWMD\n" +
            "    LEFT JOIN OVERSEA_WHS_MOVE OWM ON OWMD.UUID = OWM.UUID\n" +
            "    LEFT JOIN MATERIAL_SAP MS ON OWMD.MATERIAL_NO = MS.MATERIAL_NO\n" +
            "WHERE OWMD.UUID = #{uuid}\n" +
            "ORDER BY TO_NUMBER(OWMD.ITEM_NO) ")
    List<Map<String, Object>> getOverseaWhsMoveDtlList(@Param("uuid") String uuid);
}
